<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>我的考试</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }

	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/teach/teachStudentPaper/stuExamList/">考试列表</a></li>
		<%--<shiro:hasPermission name="teach:teachExam:edit"><li><a href="${ctx}/teach/teachExam/form">考试管理添加</a></li></shiro:hasPermission>--%>
	</ul>
	<form:form id="searchForm" modelAttribute="teachExam" action="${ctx}/teach/teachStudentPaper/stuExamList/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<%--<input id="ifcheckedAn" name="ifcheckedAn" type="hidden" value="${ifcheckedAn}"/>--%>
		<ul class="ul-form">
			<li><label>科目名称：</label>
				<%--<form:input path="examName" htmlEscape="false" maxlength="64" class="input-medium"/>--%>
				<input id="examName" name="examName" value="${teachExam.examName}" class="input-medium" type="text">
			</li>
			<li>&nbsp;&nbsp;考试开始时间范围：&nbsp;<input id="beginBeginDate" name="beginBeginDate" type="text" readonly="readonly" maxlength="40" class="input-mini Wdate beginDateInput" style="width: 150px"
									  value="<fmt:formatDate value="${teachExam.beginBeginDate}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
				&nbsp;--&nbsp;&nbsp;<input id="beginEndDate" name="beginEndDate" type="text" readonly="readonly" maxlength="40" class="input-mini Wdate endDateInput" style="width: 150px"
										   value="<fmt:formatDate value="${teachExam.beginEndDate}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</li>
			<li>&nbsp;&nbsp;考试结束时间范围：&nbsp;<input id="endBeginDate" name="endBeginDate" type="text" readonly="readonly" maxlength="40" class="input-mini Wdate beginDateInput" style="width: 150px"
									  value="<fmt:formatDate value="${teachExam.endBeginDate}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
				&nbsp;--&nbsp;&nbsp;<input id="endEndDate" name="endEndDate" type="text" readonly="readonly" maxlength="40" class="input-mini Wdate endDateInput" style="width: 150px"
										   value="<fmt:formatDate value="${teachExam.endEndDate}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</li>
			<%--20170611测试，AlisaYe
			待完善所有和查询相关的部分--%>
			<%--<li><label>考试状态：</label>--%>
				<%--<form:select path="examStatus" class="input-medium">--%>
					<%--<form:option value="" label=""/>--%>
					<%--<form:options items="${fns:getDictList('exam_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>--%>
				<%--</form:select>--%>
			<%--</li>--%>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="btns">&nbsp;&nbsp;<input id="search" class="btn btn-primary" type="button" value="重置" /></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>考试科目名称</th>
				<th>考试开始时间</th>
				<th>考试结束时间</th>
				<th>考试状态</th>
				<th>paparid</th>
				<%--<th>可参加考试次数</th>--%>
				<%--<th>是否可以查看答题情况</th>--%>
				<%--<th>更新时间</th>--%>
				<%--<th>考试成绩</th>--%>
				<%--<shiro:hasPermission name="teach:teachExam:edit">--%>
					<th>操作</th>
				<%--</shiro:hasPermission>--%>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="teachExam">
			<%
				java.util.Date dt = new Date();
				long nowTime = dt.getTime();   //得到秒数，Date类型的getTime()返回毫秒数
				request.setAttribute("nowTime", nowTime);
			%>
			<tr>
				<td>
					<%--<a href="${ctx}/teach/teachExam/form?id=${teachExam.id}">--%>
					${teachExam.examName}
				<%--</a>--%>
				</td>
				<td>
					<fmt:formatDate value="${teachExam.beginDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<fmt:formatDate value="${teachExam.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<c:if test="${(nowTime-teachExam.endDate.getTime())>0}">
						已结束
					</c:if>
					<c:if test="${(teachExam.beginDate.getTime()-nowTime)>0}">
						未开始
					</c:if>
					<c:if test="${(nowTime-teachExam.endDate.getTime())<0&&(teachExam.beginDate.getTime()-nowTime)<0}">
						考试开放中
					</c:if>
					<%--${fns:getDictLabel(teachExam.examStatus, 'exam_status', '')}--%>
				</td>
				<td>
						${teachExam.paperId}
				</td>
				<%--<td>--%>
					<%--${teachExam.examFrequency}--%>
				<%--</td>--%>
				<%--<td>--%>
					<%--&lt;%&ndash;${ifcheckedAn}&ndash;%&gt;--%>
						<%--<c:if test="${teachExam.ifCheckAnswer==1}">--%>
							<%--是--%>
						<%--</c:if>--%>
						<%--<c:if test="${teachExam.ifCheckAnswer==0}">--%>
							<%--否--%>
						<%--</c:if>--%>
						<%--<c:if test="${teachExam.ifCheckAnswer!=0&&teachExam.ifCheckAnswer!=1}">--%>
							<%--未设置--%>
						<%--</c:if>--%>

				<%--</td>--%>
				<%--<td>--%>
					<%--<fmt:formatDate value="${teachExam.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>--%>
				<%--</td>--%>
				<%--<td>--%>
<%--.--%>
				<%--</td>--%>
				<%--去掉了权限控制部分，测试有问题，带解决--%>
				<%--<shiro:hasPermission name="teach:teachExam:edit">--%>
					<td>
					<c:if test="${(nowTime-teachExam.endDate.getTime())>0}">
						<a href="${ctx}/teach/teachStudentPaper/stuExamAnswerDetail?examId=${teachExam.id}">查看答题情况</a>
					</c:if>
					<c:if test="${(teachExam.beginDate.getTime()-nowTime)>0}">
					<a href="#">考试未开始</a>
					</c:if>
					<c:if test="${(nowTime-teachExam.endDate.getTime())<0&&(teachExam.beginDate.getTime()-nowTime)<0}">
						<a href="${ctx}/teach/teachStudentPaper/stuExamDoTest?examId=${teachExam.id}">进入考试</a>
					</c:if>

				</td>
				<%--</shiro:hasPermission>--%>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	<script>
		<%--重置--%>
		var test=document.getElementById("search");
		test.onclick=function(){
			var beginBeginDate=document.getElementById("beginBeginDate");
			var beginEndDate=document.getElementById("beginEndDate");
			var endBeginDate=document.getElementById("endBeginDate");
			var endEndDate=document.getElementById("endEndDate");
			var examName=document.getElementById("examName");
			beginBeginDate.value = null;
			beginEndDate.value = null;
			endBeginDate.value = null;
			endEndDate.value = null;
			examName.value = null;
		};
	</script>
</body>
</html>